//package com.navinfo.opentsp.platform.computing.analysis.application;
//
//
//import com.navinfo.opentsp.platform.computing.analysis.service.*;
//import com.navinfo.opentsp.platform.computing.analysis.util.DateUtils;
//import org.apache.spark.SparkContext;
//import org.apache.spark.api.java.JavaSparkContext;
//import org.apache.spark.sql.SparkSession;
//
//import java.util.Date;
//
///**
// * 车辆载荷应用入口
// * arg[0]:monthmetrics/stageduration
// * arg[1]:yyyy_MM_dd
// * args sample1: monthmetrics 2018_08_25
// * args sample2: stageduration 2018_12_03
// * args sample3: stageslopeduration 2018_12_03
// * args sample4: stageoldduration 2018_12_03
// * args sample5: stagebrakeduration 2018_12_03
// * args sample6: stageslopedetailduration 2018_12_03
// * args sample7: stageslope4dwduration 2018_12_03
// */
//public class TruckloadApplication {
//    public static void main(String[] args) {
////        SparkConf sc = new SparkConf().setAppName("TruckLoadMonthMetrics");
////        //spark相关配置
////        Map<String, String> props = PropertiesUtil.getProperties();
////        for (Map.Entry<String, String> entry : props.entrySet()) {
////            if (entry.getKey().startsWith("spark.")) {
////                sc.set(entry.getKey(), entry.getValue());
////                System.out.println(entry.getKey()+"="+ entry.getValue());
////            }
////        }
//        //TODO:提交代码时，需要备注37,40,43,44行
////        System.setProperty("hadoop.home.dir", "c:\\winutils\\");
//        SparkSession spark = SparkSession
//                .builder()
////                .master("local")
//                .appName("TruckLoadDurationAll")
//                .config("spark.serializer", "org.apache.spark.serializer.KryoSerializer")
//                .config("spark.kryoserializer.buffer.max","512m")
////                .config("spark.sql.warehouse.dir", "hdfs://nhdp1.hadoop.com:8020/apps/hive/warehouse")
////                .config("spark.sql.hive.metastore.jars","maven")
//                .enableHiveSupport()
//                .getOrCreate();
//
//        SparkContext context = spark.sparkContext();
//        JavaSparkContext jsc = new JavaSparkContext(context);
//
////        JavaSparkContext jsc = new JavaSparkContext(sc);
//        //统计开始时间
//        if(args.length < 2){
//            throw new RuntimeException("type and startDay cannot be null!");
//        }
////        Date startDate = DateUtils.parse("yyyy_MM_dd", "2018_07_25");
//        Date startDate = DateUtils.parse("yyyy_MM_dd", args[1]);
//
//        //每月25号计算各车的最小和最大载荷
//        if (args[0].equalsIgnoreCase("monthmetrics")) {
//            //月级计算各车的最小和最大载荷
//            TruckLoadService service = new TruckLoadService();
//            service.init(jsc, startDate);
//            // 载荷计算
//            service.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stageoldduration")) {
//            //天级计算各车的载荷情况时长
//            TruckLoadStageDurationService service_tlsd = new TruckLoadStageDurationService();
//            service_tlsd.init(jsc, startDate);
//            // 载荷情况时长计算
//            service_tlsd.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stageslopeduration")) {
//            //基于月度计算的载荷档位，天级计算各车的坡度载荷油耗关系
//            TruckLoadStageDurationGearService service_tlsdl = new TruckLoadStageDurationGearService();
//            boolean calcDayFlag = Boolean.parseBoolean(args[2]);
//            service_tlsdl.init(spark, jsc, startDate,calcDayFlag);
//            // 坡度档位油耗载荷情况时长计算
//            service_tlsdl.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stageslopedetailduration")) {
//            //基于月度计算的载荷档位，天级计算各车的坡度载荷油耗关系明细
//            TruckLoadStageDurationGearDetailService service_tlsdl = new TruckLoadStageDurationGearDetailService();
//            boolean calcDayFlag = Boolean.parseBoolean(args[2]);
//            service_tlsdl.init(spark, jsc, startDate, calcDayFlag);
//            // 坡度档位油耗载荷情况时长计算
//            service_tlsdl.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stageslope4dwduration")) {
//            //基于月度计算的载荷档位，天级计算各车的坡度载荷油耗关系-专项针对2load,-4slope,10dw,42speed
//            TruckLoadStageDurationGear4DWService service_tlsdl = new TruckLoadStageDurationGear4DWService();
//            service_tlsdl.init(spark, jsc, startDate);
//            // 坡度档位油耗载荷情况时长计算
//            service_tlsdl.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stagebrakeduration")) {
//            //临时应对潍柴发动机2018-12-12日演示需求，统计细分到马力按月统计满、半、空 刹车次数/换挡次数
//            TruckLoadStageDurationBrakeService service_tlsdl = new TruckLoadStageDurationBrakeService();
//            service_tlsdl.init(jsc, startDate);
//            // 坡度档位油耗载荷情况时长计算
//            service_tlsdl.run(jsc);
//        } else  if (args[0].equalsIgnoreCase("stageduration")) {
//            //基于车型配置的载荷档位，天级计算各车的载荷情况时长
//            TruckLoadStageDurationNewService service_tlsdl = new TruckLoadStageDurationNewService();
//            service_tlsdl.init(jsc, startDate);
//            // 载荷情况时长计算
//            service_tlsdl.run(jsc);
//        }
//        jsc.close();
//    }
//}
